@echo off
for /l %%i in (1,1,254) do (
    ping -n 1 -w 100 192.168.31.%%i >nul && echo 192.168.31.%%i is alive
)
pause